package com.dlg.commons.enums;

/**
 * 支付类型(0.橙子,1.支付宝,2.微信,3.银行卡)
 * @author mwz
 * @since  2017年4月1日 下午1:55:24
 */
public enum PaymentTypeEnum {
	
	ORANGE((short)0), ALIPAY((short)1), WCHAT((short)2), UNION((short)3), YWT((short)4), OFFLINE((short)9);
	
	private short code;

	public short getCode() {
		return code;
	}

	public void setCode(short code) {
		this.code = code;
	}

	PaymentTypeEnum(short code) {
		this.code = code;
	}
	
	public static PaymentTypeEnum getByCode(int code) {
		PaymentTypeEnum[] codes = PaymentTypeEnum.values();
		for (PaymentTypeEnum state : codes) {
			if (state.getCode() == code) {
				return state;
			}
		}
		throw new RuntimeException("不支持的支付类型");
	}
	
}
